﻿using CPPEI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SLG.Domain.Services
{
    public class BDService
    {
        public ListResult<Entities.BD_Race> GetRaces()
        {
            using (SLGDbContext dbContext = new SLGDbContext())
            {
                EntRep<Entities.BD_Race> bdrRep = new EntRep<Entities.BD_Race>(dbContext);
                List<Entities.BD_Race> list = bdrRep.Query().OrderBy(p => p.SortIndex).ToList();

                return new ListResult<Entities.BD_Race>(list);
            }
        }

        public ListResult<Views.V_BD_King> GetKings(int race)
        {
            using (SLGDbContext dbContext = new SLGDbContext())
            {
                EntRep<Views.V_BD_King> bdaRep = new EntRep<Views.V_BD_King>(dbContext);
                List<Views.V_BD_King> list = bdaRep.Query(p => p.Race == race).OrderBy(p => p.SortIndex).ToList();

                return new ListResult<Views.V_BD_King>(list);
            }
        }
    }
}
